package name.as3.cmdFrameworks.addins
{
import flash.display.DisplayObject;
import flash.utils.SafeGlobalOwner;
import flash.utils.SafeGlobalProxy;

import name.as3.cmdFrameworks.interfaces.IFacade;
import name.as3.cmdFrameworks.interfaces.addins.IMediator;

public class Mediator extends SafeGlobalOwner implements IMediator
{
	private var m_facade:IFacade;
	private var m_viewer:DisplayObject;
	/**
	 *
	 */
	public function Mediator()
	{
	}
//==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
// protected
//==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
	protected function p_onSetViewer():void
	{
		
	}
//==================================================================================================
// public
//==================================================================================================
	public function setFacade(value:IFacade, proxyGlobal:SafeGlobalProxy):void
	{
		m_facade = value;
		super.sg = proxyGlobal;
	}
	public function get facade():IFacade
	{
		return m_facade;
	}
	/**
	 * 当初始完成时
	 */
	public function onInited():void
	{
		
	}
	/**
	 * 发送消息
	 */
	public function sendNotification(strType:String, obData:* = null):void
	{
		m_facade.sendNotification(strType, obData);
	}
	/**
	 * 执行命令
	 */
	public function invokeCommand(strType:String,
								  cCommand:Class,
								  obData:* = null,
								  blIsOneoff:Boolean = false):void
	{
		m_facade.addCommand(strType, cCommand);
		this.sendNotification(strType, obData);
	}
	/**
	 * 设置绑定面板
	 */
	public function set viewer(value:DisplayObject):void
	{
		m_viewer = value;
		p_onSetViewer();
	}
	/**
	 * 获取绑定面板
	 */
	public function get viewer():DisplayObject
	{
		return m_viewer;
	}
	/**
	 * 获取面板层次
	 */
	public function get panelLayer():Number
	{
		return 0;
	}
}
}